//
//  WeatherView.m
//  FitTime
//
//  Created by dllo on 16/4/8.
//  Copyright © 2016年 赵建平. All rights reserved.
//

#import "WeatherView.h"

@implementation WeatherView

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.weatherImageView = [UIImageView new];
        self.humidityImageView = [UIImageView new];
        self.windPowerImageView = [UIImageView new];
        self.localImageView = [UIImageView new];
        self.backgroundImageView = [UIImageView new];
        
        [self addSubview:self.backgroundImageView];
        [self addSubview:self.weatherImageView];
        [self addSubview:self.humidityImageView];
        [self addSubview:self.windPowerImageView];
        [self addSubview:self.localImageView];
        
        self.temperatureLabel = [UILabel new];
        self.weatherLabel = [UILabel new];
        self.cityLabel = [UILabel new];
        self.humidityLabel = [UILabel new];
        self.windPowerLabel = [UILabel new];
        
        self.temperatureLabel.textColor = [UIColor whiteColor];
        self.weatherLabel.textColor = [UIColor whiteColor];
        self.cityLabel.textColor = [UIColor whiteColor];
        self.humidityLabel.textColor = [UIColor whiteColor];
        self.windPowerLabel.textColor = [UIColor whiteColor];
        
        [self addSubview:self.temperatureLabel];
        [self addSubview:self.weatherLabel];
        [self addSubview:self.cityLabel];
        [self addSubview:self.humidityLabel];
        [self addSubview:self.windPowerLabel];
        
        self.temperatureLabel.font = [UIFont systemFontOfSize:40 * SCALEWIDTH];
        self.humidityLabel.font = [UIFont systemFontOfSize:10 * SCALEWIDTH];
        self.windPowerLabel.font = [UIFont systemFontOfSize:10 * SCALEWIDTH];
        
        [self.backgroundImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self);
            make.left.equalTo(self);
            make.center.equalTo(self);
        }];
        
        
        [self.weatherImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.mas_top).offset(10 * SCALEHEIGHT);
            make.left.equalTo(self.mas_left).offset(10 * SCALEWIDTH);
            make.bottom.equalTo(self.mas_bottom).offset(-10 * SCALEHEIGHT);
            make.width.equalTo(self.mas_height);
        }];
        
        [self.temperatureLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.weatherImageView.mas_top);
            make.left.equalTo(self.weatherImageView.mas_right).offset(10 * SCALEWIDTH);
            make.height.equalTo(@(40 * SCALEHEIGHT));
        }];
        
        [self.weatherLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.temperatureLabel.mas_right);
            make.bottom.equalTo(self.temperatureLabel.mas_bottom);
            make.height.equalTo(@(30 * SCALEHEIGHT));
        }];
        
        [self.cityLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.temperatureLabel.mas_bottom);
            make.left.equalTo(self.temperatureLabel.mas_left);
            make.bottom.equalTo(self.humidityImageView.mas_top);
        }];
        
        [self.localImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.cityLabel.mas_top);
            make.left.equalTo(self.cityLabel.mas_right);
            make.bottom.equalTo(self.cityLabel.mas_bottom);
            make.size.mas_equalTo(CGSizeMake(15 * SCALEWIDTH, 15 * SCALEWIDTH));
        }];
        
        [self.humidityImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.humidityImageView.mas_top);
            make.bottom.equalTo(self.weatherImageView.mas_bottom);
            make.left.equalTo(self.cityLabel.mas_left);
            make.width.height.equalTo(@(20 * SCALEWIDTH));
        }];
        
        [self.humidityLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.humidityImageView.mas_top);
            make.left.equalTo(self.humidityImageView.mas_right).offset(5);
            make.bottom.equalTo(self.humidityImageView.mas_bottom);
        }];
        
        [self.windPowerImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.humidityImageView.mas_top);
            make.left.equalTo(self.humidityLabel.mas_right).offset(5);
            make.bottom.equalTo(self.humidityImageView.mas_bottom);
            make.width.equalTo(@(20 * SCALEWIDTH));
        }];
        
        [self.windPowerLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.humidityImageView.mas_top);
            make.left.equalTo(self.windPowerImageView.mas_right).offset(5);
            make.bottom.equalTo(self.humidityImageView.mas_bottom);
        }];
        
        
        
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
